<!-- $Id: goods_list.htm 17126 2010-04-23 10:30:26Z liuhui $ -->

{if $full_page}
{include file="pageheader.htm"}

{insert_scripts files="../js/utils.js,listtable.js,jquery.js"}
<script type="text/javascript">
  listTable.query = "query";
</script>
<!-- 商品搜索 -->

<!-- $Id: goods_search.htm 16790 2009-11-10 08:56:15Z wangleisvn $ -->
<div class="form-div">
  <form action="javascript:searchGoods()" name="searchForm">
    <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
    {if $smarty.get.act neq "trash"}
    <!-- 分类 -->
    地区
    <!-- 办事处 -->
    <select name="area_id">
        <option value=''>全部</option>
    {foreach from=$agency_list item=agency}
        <option value="{$agency.agency_id}">{$agency.agency_name}</option>
    {/foreach}
    </select>
    {/if}
    <!-- 关键字 -->
    {$lang.keyword} <input type="text" name="keyword" size="15" />
    <input type="date" name="promote_start_date" class="data" value="{$time_start}">
    <input type="date" name="promote_end_date" class="data" value="{$time_end}">
    <input type="submit" value="{$lang.button_search}" class="button" />
  </form>
</div>

{literal}
<script language="JavaScript">
    function searchGoods()
    {
{/literal}
        listTable.filter['promote_start_date'] = document.forms['searchForm'].elements['promote_start_date'].value;
        listTable.filter['promote_end_date'] = document.forms['searchForm'].elements['promote_end_date'].value;
{literal}
        listTable.filter['keyword'] = document.forms['searchForm'].elements['keyword'].value;
        listTable.filter['area_id'] = Utils.trim(document.forms['searchForm'].elements['area_id'].value);
        listTable.filter['page'] = 1;
        listTable.loadList();
    }
</script>
{/literal}

<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="return confirmSubmit(this)">
  <!-- start goods list -->
  <div class="list-div" id="listDiv">
{/if}
<table cellpadding="3" cellspacing="1">
  <tr>
    <th>ID</th>
    <th>SKU</th>
    <th>名称</th>
    <th>地区</th>
    <th>商品库存</th>
    <th>闪购数</th>
    <th>限制数</th>
    <th>被买数</th>
    <th>显示被买数</th>
    <th>闪购价</th>
    <th>开始时间</th>
    <th>结束时间</th>
    <th>操作</th>
  </tr>
  {foreach from=$limit_list item=goods}
  <tr class="limit_box">
    <td align="center">{$goods.goods_id}</td>
    <td align="center">{$goods.goods_sku}</td>    
    <td align="center" class="name" >{$goods.goods_name|escape:html}</td>
    <td align="center">{$goods.area_name}</td>
    <td align="center">{$goods.goods_stock}</td>
    <td align="center"><input type="text" name="goods_num" class="goods_num" {if $goods.is_stock eq 1}disabled="disabled"{/if} value="{$goods.goods_num} " style="width:20px;"> </td>
    <td align="center"><input type="text" name="limit_num" class="limit_num" {if $goods.is_stock eq 1}disabled="disabled"{/if} value="{$goods.limit_num}" style="width:20px;">  </td>
    <td align="center">{$goods.buy_num}</td>
    <td align="center"><input type="text" name="buy_number" class="buy_number" {if $goods.is_stock eq 1}disabled="disabled"{/if} value="{$goods.buy_number}" style="width:20px;"></td>
    <td align="center"><input type="text" name="promote_price" class="promote_price" {if $goods.is_stock eq 1}disabled="disabled"{/if} value="{$goods.promote_price}" style="width:30px;"></td>
    <td align="center">{$goods.promote_start_date}</td>
    <td align="center">{$goods.promote_end_date}</td>
    <td align="center">{if $goods.is_stock eq 0}<a onclick="edit_num(this,{$goods.limit_id});" >编辑</a> 
      <a onclick="delete_limit(this,{$goods.limit_id});" class="delete">删除</a> <a onclick="count_stock({$goods.limit_id});">清点库存</a>{else}已清点{/if}</td>
  </tr>
  {foreachelse}
  <tr><td class="no-records" colspan="12">{$lang.no_records}</td></tr>
  {/foreach}
</table>
<!-- end goods list -->

<!-- 分页 -->
<table id="page-table" cellspacing="0">
  <tr>
    <td align="right" nowrap="true">
    {include file="page.htm"}
    </td>
  </tr>
</table>

{if $full_page}
</div>


</form>

<script type="text/javascript">
  function edit_num(obj,limit_id){
    var goods_num = $(obj).parents('.limit_box').find('.goods_num').val();//闪购数量
    var limit_num = $(obj).parents('.limit_box').find('.limit_num').val();//限制数量
    var promote_price = $(obj).parents('.limit_box').find('.promote_price').val();//闪购价
    var buy_number = $(obj).parents('.limit_box').find('.buy_number').val();//闪购价
    var url="limit.php?act=edit_limit";
    Ajax.call(url, 'goods_num=' + goods_num+'&limit_num='+limit_num+'&limit_id='+limit_id+'&promote_price='+promote_price+'&buy_number='+buy_number, edit_return, 'POST', 'JSON');

  }

  function edit_return(data){
    alert(data.content);
  }


  function count_stock(limit_id){
    var url="limit.php?act=count_stock";
    Ajax.call(url, 'limit_id=' + limit_id, count_stock_return, 'POST', 'JSON');
  }

  function count_stock_return(data){
    alert(data.content);
  }
  function delete_limit(obj,limit_id){
    var goods_name = $(obj).parents('.limit_box').find('.name').html();//限制数量
    $(".limit").removeClass('delete_now');
    var confirm=window.confirm("点击确定删除"+goods_name);
    if(confirm){
    var url="limit.php?act=delete_stock";
    Ajax.call(url, 'limit_id=' + limit_id, delete_limit_return, 'POST', 'JSON');
    $(obj).parents('.limit_box').addClass('delete_now');
    }
    else{
      
    }





  }
  function delete_limit_return(data){
    if(data.error == 1){
      $('.delete_now').remove(); 
    }
  }


  listTable.recordCount = {$record_count};
  listTable.pageCount = {$page_count};

  {foreach from=$filter item=item key=key}
  listTable.filter.{$key} = '{$item}';
  {/foreach}





</script>

{/if}